The present invention relates to a pneumatic or hydraulic cylinder formed of a cylinder tube made of non-ferromagnetic material with a movable piston therein and at least one signal transmitter located in one or more longitudinal channels in the cylinder tube and from each of which a signal lead extends for indicating the location of the piston within the cylinder tube, the signal transmitters being secured in the longitudinal grooves by means of screws and detecting the position of the piston in the cylinder tube by detecting the magnetic field of a permanent magnet on the piston.